Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fully qualitfied USSD command #14

Open
ephraimm opened this issue Apr 16, 2019 · 3 comments
Open

fully qualitfied USSD command #14

ephraimm opened this issue Apr 16, 2019 · 3 comments

Comments

@ephraimm
Copy link

ephraimm commented Apr 16, 2019

How do I handle a user sending through a full ussd command on session initialisation?

"*1234*1*1*9876#"

where 1234 is the shortcode and 119876 the preconfigured responses?

@yono38
Copy link
Contributor

yono38 commented May 1, 2019

Hey @ephraimm - sorry about the delayed response.

According to the Africa's Talking docs on the text param: "This shows the user input. It is an empty string in the first notification of a session. After that, it concatenates all the user input within the session with a * until the session ends."

Because of this limitation on the provider side, I don't think this feature will be currently possible. I will try reaching out to AT to see if they would be willing to provide the full string on the session initiation.

This is a feature that has been requested by our customers as well, so I am currently trying to see if I can do something like this on our Ghana Hubtel app.

I'll keep this thread posted if I have any success on the AT or Hubtel fronts.

@ephraimm
Copy link
Author

ephraimm commented May 2, 2019

Thanks for the info. so this is something that is managed by the networks or by WASPs (AT and the like) or is it both?
(We are using the menu builder with a different WASP)

@habbes
Copy link
Owner

habbes commented May 2, 2019

@ephraimm you could probably make it work by transforming your input into something the library expects (which was initially built with the Africa's Talking API in mind):

function covertFullSessionCommand (command) {
  const [serviceCode, ...rest] = command.slice(1, -1).split('*');
  return { serviceCode, text: rest.join('*') }
}

const { serviceCode, text } = covertFullSessionCommand('*1234*1*1*9876#');
console.log(serviceCode, text);

menu.run({ serviceCode, text, phoneNumber: '07...', sessionId: 'dsfdsf' }, callback);

Does this address your problem?

This is obviously a hack, but let me know if it works for you. I think the ideal thing would be to re-write the library in such a way as USSD API providers can be implemented as adapters on top of a provider-agnostic base. Maybe if I get time I could work on that, but I can't give out an ETA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants