Genesys Cloud - Main

 View Only

Sign Up

Expand all | Collapse all

Campaign Start/Stop from Restful API

  Thread closed by the administrator, not accepting new replies.
  • 1.  Campaign Start/Stop from Restful API

    Posted 02-08-2023 00:03
    No replies, thread closed.
    Hello,

    We are looking to use restful API to start and stop campaign. Did try to see developer portal but didn't see any specific API available for running/stopping the campaign. 

    Please let me know if it's possible to perform campaign start/stop from RestAPI.
    #Outbound

    ------------------------------
    Rakesh Jha
    Servion Global Solutions
    ------------------------------


  • 2.  RE: Campaign Start/Stop from Restful API

    Posted 02-08-2023 15:39
    No replies, thread closed.
    I haven't tried it my self but PUT /api/v2/outbound/campaigns/{campaignId} should allow you to change the status of the campaign.

    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 3.  RE: Campaign Start/Stop from Restful API

    Posted 02-08-2023 15:45
    No replies, thread closed.
    Jan is correct, you can start and stop campaigns with: PUT /api/v2/outbound/campaigns/{campaignId}.... the field to update is campaignStatus.

    campaignStatus
    (string) The current status of the Campaign. A Campaign may be turned 'on' or 'off'. Required for updates.Valid values: on, stopping, off, complete, invalid, forced_off, forced_stopping.


    ------------------------------
    Blake Anderson | Sr. Telecom Engineer
    BEST BUY CO., INC.
    ------------------------------



  • 4.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 04:07
    No replies, thread closed.

    Thanks Blake. I tried to use 

    /api/v2/outbound/campaigns/{campaignId}

    {
      "campaignStatus": "off",
      "name": "Campaign",
      "dialingMode": "progressive"
    }

    But getting below error-

    { "message": "An attempt was made to update a Campaign in an invalid way. Details: A campaign cannot be updated while running", "code": "invalid.update.campaign.active", "status": 400, "messageWithParams": "An attempt was made to update a {entity} in an invalid way. Details: {INVALID_UPDATE_CAMPAIGN_ACTIVE}", "messageParams": { "INVALID_UPDATE_CAMPAIGN_ACTIVE": "A campaign cannot be updated while running", "entity": "Campaign" }, "contextId": "6b2eb42f-ccdc-4f1a-8512-da50ab0a0af6", "details": [], "errors": [] }



    ------------------------------
    Rakesh Jha
    Servion Global Solutions
    ------------------------------



  • 5.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 05:40
    No replies, thread closed.

    Try sending only campaignStatus and version, it seems to require the current version when doing updates so you'll need to fetch that first.

    /api/v2/outbound/campaigns/{campaignId}

    {
      "campaignStatus": "off",
      "version": 0
    }



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 6.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 05:50
    No replies, thread closed.

    Hi Jan,

    Thanks for response. Tried below -

    PUT /api/v2/outbound/campaigns/bd3997be-2c60-4aad-984f-68a3e2f9274d HTTP/1.1 Host: api.mypurecloud.de Authorization: Bearer ************************************************************************************** Content-Type: application/json {"version":88,"name":"Campaign","campaignStatus":"off"}

    But getting same error-

    { "message": "An attempt was made to update a Campaign in an invalid way. Details: A campaign cannot be updated while running", "code": "invalid.update.campaign.active", "status": 400, "messageWithParams": "An attempt was made to update a {entity} in an invalid way. Details: {INVALID_UPDATE_CAMPAIGN_ACTIVE}", "messageParams": { "INVALID_UPDATE_CAMPAIGN_ACTIVE": "A campaign cannot be updated while running", "entity": "Campaign" }, "contextId": "45755593-55b1-4cf1-8243-9eaef121c45f", "details": [], "errors": [] }



    ------------------------------
    Rakesh Jha
    Servion Global Solutions
    ------------------------------



  • 7.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 06:04
    No replies, thread closed.

    try without "name":"Campaign"



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 8.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 06:21
    No replies, thread closed.

    PUT /api/v2/outbound/campaigns/bd3997be-2c60-4aad-984f-68a3e2f9274d HTTP/1.1 Host: api.mypurecloud.de Authorization: Bearer ************************************************************************************** Content-Type: application/json

     {"version":88,"campaignStatus":"off"}

    Response-

    { "message": "Name is required.", "code": "name.required", "status": 400, "contextId": "78a43d7e-80f5-486b-9433-59d1ddf76875", "details": [], "errors": [] }



    ------------------------------
    Rakesh Jha
    Servion Global Solutions
    ------------------------------



  • 9.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 06:22
    No replies, thread closed.

    Seems name required



    ------------------------------
    Rakesh Jha
    Servion Global Solutions
    ------------------------------



  • 10.  RE: Campaign Start/Stop from Restful API

    Posted 02-13-2023 07:53
    No replies, thread closed.

    Well, this was an interesting one. Seems you need to send in the whole configuration with the status change.

    I pulled the configuration with GET /api/v2/outbound/campaigns/{campaignId}
    Removed the selfUri entries and used PUT to change the campaignStatus.

    With this I could change status between on and off (using the correct version value)

    {
      "id": "07f00b5b-2ecf-4c11-861a-9c356922d298",
      "name": "Lab Dialer",
      "version": 2,
      "contactList": {
        "id": "36ad6a5c-54ca-4738-bbc7-cb77eced36c6",
        "name": "Lab Lista"
      },
      "queue": {
        "id": "5eca9a9d-51f4-4d52-8b20-514ce42588c0",
        "name": "Lab"
      },
      "dialingMode": "preview",
      "script": {
        "id": "476c2b71-7429-11e4-9a5b-3f91746bffa3",
        "name": "Default Outbound Script"
      },
      "campaignStatus": "off",
      "phoneColumns": [
        {
          "columnName": "tele",
          "type": "Cell"
        }
      ],
      "abandonRate": 5,
      "dncLists": [],
      "callerName": "Dialer",
      "callerAddress": "+46",
      "outboundLineCount": 0,
      "ruleSets": [],
      "skipPreviewDisabled": false,
      "previewTimeOutSeconds": 0,
      "singleNumberPreview": false,
      "alwaysRunning": false,
      "noAnswerTimeout": 30,
      "priority": 5,
      "contactListFilters": [],
      "division": {
        "id": "05633e2c-20ec-4242-ae98-cc3304b80256",
        "name": "Lab"
      },
      "dynamicContactQueueingSettings": {
        "sort": false
      }
    }



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 11.  RE: Campaign Start/Stop from Restful API

    Posted 08-10-2023 16:05
    No replies, thread closed.

    Hello Jan,

    I have similar problem, could you please help me with the TranslationMap syntax to collect all the API response in one output variable. so that I can pass the details in a variable for my next data action(most probably to start and stop the campaign remotely(using  PUT API request).

    For example If the existing  response is showing the campaign status is "off" and If I am going to set it "on"  as a API input.

    In this case, system will consider which input, the one which is inside the body of the JSON data or the one which we are passing as a external Input  using Input_Contract variable.

    Thanks a lot.



    ------------------------------
    Devanand Gawande
    Capgemini Brasil S.A.
    ------------------------------



  • 12.  RE: Campaign Start/Stop from Restful API

    Posted 08-11-2023 11:00
    No replies, thread closed.

    Hi Devanand,

    I've only done this through a custom application but it should work just as well from a data action.

    You shouldn't need any TranslationMap for this, but your Output Contract would need to match the result you're expecting.

    Unless you have several campaigns you need to control the simple solution would be to just have a data action with the PUT data static except campaignStatus and version.



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 13.  RE: Campaign Start/Stop from Restful API

    Posted 08-15-2023 05:41
    No replies, thread closed.

    Thanks,

    @Charaf Eddine Chemlal helped me with the below string. and it worked...!!!

    To create a JSON response, you must escape strings using the following macro:

    $esc.jsonString(${input.json})

    To learn more about velocity macros, you can refer to this link.

    So, within your success template, you should apply the macro to the campaignData defined in your output contract:

    {
      "translationMap": {},
      "translationMapDefaults": {},
      "successTemplate": "{\"campaignData\": \"$esc.jsonString(${rawResult})\"}"
    }



    ------------------------------
    Devanand Gawande
    Capgemini Brasil S.A.
    ------------------------------



  • 14.  RE: Campaign Start/Stop from Restful API

    Posted 12-06-2023 06:02
    No replies, thread closed.

    Hi Jan,
    thanks for your solution. I do not think I would have puzzled this out on myself. Works fine.

    Best regards
    Christoph



    ------------------------------
    Christoph Domaschke
    CRONBANK AG
    ------------------------------