Whispir Forums

Getting Started

RSS Feed

Start a scenario using the API?

    • Rich
    • Topic created 4 years ago

    Is it possible to start a scenario using the API?

    I can see API calls to retrieve the list of scenarios, or a single scenario, but it is not clear whether you can start a scenario using the API.

    thanks in advance

    Message edited by Rich 4 years ago

  1. Jordan Walsh4 years ago

    Hi Rich,

    Yes it's possible to start a sceanrio. You simply send a POST message to the sceneario ID. e.g.

    1. POST /scenarios/ABC1234BCDEFF34ADCCE
    2. Authorization: Basic abdb2384789cbadbsd9023==

    This will cause your scenario to be invoked as it has been configured.

    Cheers

    Jordan

  2. Rich4 years ago

    Hi Jordan,

    Thanks for getting back to me.

    Is it possible to include parameters when starting a scenario?

    eg if we wanted to create the following simple scenario:

    1. email everyone with a message, including a method for them to confirm they have read it
    2. After 20 minutes has elapsed, send an SMS to all users who haven't confirmed they have read the email

    The message would be different every time the scenario is started, and the SMS message may be different (shorter) than the message sent in the email.

    Is it possible to pass the Subject, SMS text and email text as parameters to the scenario? I can also envisage cases where it would be desirable to pass the list of recipients to a scenario - is this possible?

    thanks in advance

  3. Jordan Walsh4 years ago

    Hi Rich

    You've got the right idea, but unfortunately the technology is a bit behind! Scenarios are currently a single step process. When using Scenarios, you're essentially just utilising a way to quickly trigger a predefined message.

    We've had the vision of scenarios being a mutli-step process for a while, and this will likely be part of a few changes to the API in the near future.

    At the moment, you'll need to code this logic into your application, rather than having this predefined in Whispir. You can utilise API Callbacks for the responses to see who has confirmed, and for the people who haven't confirmed after 10 minutes, you'll need to send a new message.

    One way to set it up, you could ask the recipients to simply respond with 'CONFIRM' in the subject. You can then use the MessageResponses query to determine who has responded to your message e.g.

    /messages/F36D04BA0022CAA8/messageresponses
    

    This would return the list of responses to this message.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns2:return xmlns:ns2="http://schemas.api.whispir.com/dap" xmlns:ns3="http://schemas.api.whispir.com">
        <ns2:link uri="http://api.whispir.com/messages/F36D04BA0022CAA8/messageresponses" rel="self" method="GET"/>
        <ns2:messageresponses>
            <ns2:response type="notmatched">
                <percentageTotal>100%</percentageTotal>
                <responseCount>1</responseCount>
            </ns2:response>
        </ns2:messageresponses>
    </ns2:return>
    

    From here you can make this a bit more detailed by adding the view parameter:

    /messages/F36D04BA0022CAA8/messageresponses?view=detailed
    

    The response to this looks like:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns2:return xmlns:ns2="http://schemas.api.whispir.com/dap" xmlns:ns3="http://schemas.api.whispir.com">
        <status>1 to 1 of 1    </status>
        <ns2:messageresponses>
            <ns2:response>
                <from>
                    <email></email>
                    <mobile>61xxxxxxxxx</mobile>
                    <mri>61xxxxxxxxx</mri>
                    <name>61xxxxxxxxx</name>
                    <voice></voice>
                </from>
                <responseCategory>notmatched</responseCategory>
                <responseMessage channel="SMS">
                    <acknowledged>21/03/14 09:24</acknowledged>
                    <content>My response</content>
                </responseMessage>
            </ns2:response>
        </ns2:messageresponses>
    </ns2:return>
    

    Notice the responseCategory is currently set to notmatched.

    Now, if you started to search these responses, you could then filter for the words you're looking for e.g. to find the responses that start with the word My

    /messages/F36D04BA0022CAA8/messageresponses?searchCriteria=startsWith&searchValue=my&view=detailed
    

    The valid values for searchCriteria are:

    1. startsWith (default)
    2. contains
    3. notcontains
    4. exactMatch

    This now returns you the matched searches also:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns2:return xmlns:ns2="http://schemas.api.whispir.com/dap" xmlns:ns3="http://schemas.api.whispir.com">
        <status>1 to 1 of 1    </status>
        <ns2:messageresponses>
            <ns2:response>
                <from>
                    <email></email>
                    <mobile>61xxxxxxxxx</mobile>
                    <mri>61xxxxxxxxx</mri>
                    <name>61xxxxxxxxx</name>
                    <voice></voice>
                </from>
                <responseCategory>matched</responseCategory>
                <responseMessage channel="SMS">
                    <acknowledged>21/03/14 09:24</acknowledged>
                    <content>My response</content>
                </responseMessage>
            </ns2:response>
        </ns2:messageresponses>
    </ns2:return>
    

    Using this logic, you should be able to search for the responses you're after, and perform a subsequent sendout to those that do not match the appropriate criteria.

    Note: You can also search a specific channel's results by adding the channel parameter. Valid values for this are:

    1. all (default)
    2. sms
    3. email
    4. web
    5. voice

    As I mentioned above, we have a few enhancements within Whispir that will assist in simplifying this process lined up in the coming releases. I'll make sure to notify yourself when they are due for release.

    Hope this helps.

    Regards

    Jordan

[ Page 1 of 1 ]