-1

I would like to find out whether one can use a script to query a user some data through kannel.

Usecase

Consider a scenario where I need to carry out a registration process via sms. I need to query for the name, birthdate, gender and so forth.

Suggestions highly appreciated.

Progress

I have tried doing so using the sms-service;

# SMS SERVICE
group = sms-service
keyword = limo
get-url = "http://localhost:3000/client?sender=%p&text=%k"
accept-x-kannel-headers = true
max-messages = 3
concatenation = true

In this case I am relying on get-url to extract the sender's msisdn. Upon receipt of the keyword "limo", I would like to start prompting the user for their name, birthdate, gender etc...in a step wise manner.

When a user sends "limo", I will respond using a question, for example, "Reply with your name?". The user may text back "Willy". I would like to retrieve and store this in the data base and prompt for the birthdate which i will in turn also store in the database.

The challenge is to extract these responses effectively from smsbox.log as well as handle the session.

Brayoni
  • 15
  • 1
  • 6

1 Answers1

0

Yes, this is possible. Setting up Kannel for this is pretty much straight forward (https://jasonrogena.github.io/2014/01/18/kannel-and-the-huawei-e160.html). You will, however, have to manage your sessions on your own as Kannel is stateless.

Update

  1. You don't need to extract anything from the log files (processing log files is highly discouraged). Everything you need in this scenario can be passed into your script (specified by the get-url variable)

  2. I think the GET request variables you have specified in our get-url are a bit fucked up. Use "http://localhost:3000/client?phone=%p&text=%a" instead.

  3. Handling sessions is pretty easy:
    • In your database, have a table that will store sessions. Make the sender's phone number the primary key for this table. The table should probably have another column for storing the last registration step (in your case, you can declare it as an ENUM('name','birthdate','gender')). I'll refer to this column as the last_step column.
    • When your script is called by Kannel, check if the sender's number is in the session table.
    • If the sender is not in the session table, add a new row with the primary_key = the phone number and last_step = 'name'. You should probably then send the sender a text message asking them to provide their name.
    • If the sender is in the session table, check what the value of last_step is for that particular number is. If last_step = 'name', your code should assume that the sender has just sent their name. Store the received SMS as the name in your DB. Update last_step = 'birthdate' then send an SMS to the sender asking them to provide their birth date.
    • Follow this logic until the user finishes the registration process.