Examples - Motion API
Create a new contact in a specific list
Initially you have to create a List, if you don' t have one. Use the following command:
curl https://{domain}/api/cm/lists -d '{"name": "list1", "description": "A brief description of my list"}' -H "Content-Type: application/json" -v -u {name}:{password} -X POST
In case of successful creation, you will get a response similar to this:
{
"id": 12,
"name": "list1",
"description": "A brief description of my list",
"updatedAt": "2017-07-13T15:42:06Z",
"createdAt": "2017-07-13T15:42:06Z"
}
A this point you can use the contact creation API and the id of the list you just created (or the id of one of your already existing lists) to create the new contact:
curl https://{domain}/api/cm/contacts -d '{"firstName": "John", "lastName": "doe", "phone": "1234567890", "ListId": 12}' -v -u {name}:{password} -X POST
In case you have some custom fields in the list and wants to populate them, you can assign the value using the sintax "cf_{your customfield id}":
curl https://{domain}/api/cm/contacts -d '{"firstName": "John", "lastName": "doe", "phone": "1234567890", "ListId": 12, "cf_1": "some text", "cf_3": "some other text"}' -v -u {name}:{password} -X POST
Create Queue Campaign
POST /api/voice/queues
BODY:
{
"dialActive":true,
"type":"outbound",
"dialCheckDuplicateType":"always", //this field specify if you want to check for duplicates only in the hopper contacts, meaning only the contacts that still need to be called (value=onlyIfOpen), or also in the hopper_final, meaning also to check in the contacts that have already been called. To disable it set it to never.
"dialCutDigit":0,
"autopause":"no",
"ringinuse":"no",
"timeoutrestart":"no",
"setinterfacevar":"no",
"setqueuevar":"no",
"setqueueentryvar":"no",
"dialOrderByScheduledAt":"ASC",
"dialGlobalInterval":"07:00-22:00,*,*,*",
"dialAMDInitialSilence":2500,
"dialAMDGreeting":1500,
"dialAMDAfterGreetingSilence":800,
"dialAMDTotalAnalysisTime":5000,
"dialAMDMinWordLength":100,
"dialAMDBetweenWordsSilence":50,
"dialAMDMaximumNumberOfWords":3,
"dialAMDSilenceThreshold":256,
"dialAMDMaximumWordLength":5000,
"dialMethod":"progressive",
"dialPowerLevel":1,
"dialPredictiveOptimization":"dropRate",
"dialPredictiveOptimizationPercentage":3,
"dialPredictiveInterval":10,
"dialLimitQueue":0,
"dialRandomLastDigitCallerIdNumber":0,
"dialOriginateTimeout":30,
"dialQueueOptions":"tTxX",
"dialQueueTimeout":3,
"strategy":"rrmemory",
"timeout":3,
"retry":3,
"weight":1,
"dialGlobalMaxRetry":4,
"dialCongestionMaxRetry":3,
"dialCongestionRetryFrequency":150,
"dialBusyMaxRetry":3,
"dialBusyRetryFrequency":150,
"dialNoAnswerMaxRetry":3,
"dialNoAnswerRetryFrequency":150,
"name":"TestCampaign",
"TrunkId":12,
"IntervalId":11
}
You'll get a response containing the id
{
...
"id":59,
...
}
curl example:
curl https://yourserver.com/api/voice/queues -H 'Content-Type: application/json' -d '{"dialActive":true,"type":"outbound","dialCheckDuplicateType":"always","dialCutDigit":0,"autopause":"no","ringinuse":"no","timeoutrestart":"no","setinterfacevar":"no","setqueuevar":"no","setqueueentryvar":"no","dialOrderByScheduledAt":"ASC","dialGlobalInterval":"07:00-22:00,*,*,*","dialAMDInitialSilence":2500,"dialAMDGreeting":1500,"dialAMDAfterGreetingSilence":800,"dialAMDTotalAnalysisTime":5000,"dialAMDMinWordLength":100,"dialAMDBetweenWordsSilence":50,"dialAMDMaximumNumberOfWords":3,"dialAMDSilenceThreshold":256,"dialAMDMaximumWordLength":5000,"dialMethod":"progressive","dialPowerLevel":1,"dialPredictiveOptimization":"dropRate","dialPredictiveOptimizationPercentage":3,"dialPredictiveInterval":10,"dialLimitQueue":0,"dialRandomLastDigitCallerIdNumber":0,"dialOriginateTimeout":30,"dialQueueOptions":"tTxX","dialQueueTimeout":3,"strategy":"rrmemory","timeout":3,"retry":3,"weight":1,"dialGlobalMaxRetry":4,"dialCongestionMaxRetry":3,"dialCongestionRetryFrequency":150,"dialBusyMaxRetry":3,"dialBusyRetryFrequency":150,"dialNoAnswerMaxRetry":3,"dialNoAnswerRetryFrequency":150,"name":"TestCampaign","TrunkId":12,"IntervalId":11}' -v -u admin:password -X POST
Create a list
POST /api/cm/lists
BODY:
{
"name":"TestList"
}
You'll get a response containing the id
{
"id":32,
"name":"TestList",
"updatedAt":"2019-07-25T09:29:42Z",
"createdAt":"2019-07-25T09:29:42Z"
}
curl example:
curl https://yourserver.com/api/cm/lists -H 'Content-Type: application/json' -d '{"name":"TestList"}' -v -u admin:password -X POST
Associate one or more lists to campaign
POST /api/voice/queues/{campaignid}/lists
BODY:
{
"id":{campaignid},
"ids":[ListId1, ListId2, etc..]
}
curl example:
curl https://yourserver.com/api/voice/queues/59/lists -H 'Content-Type: application/json' -d '{"id":59,"ids":[32, 33]}' -v -u admin:password -X POST
Add one or more agents to campaign
POST /api/voice/queues/{campaignid}/users
BODY:
{
"id":{campaignid},
"ids":[
AgentId1,
AgentId2,
AgentId3,
...
],
"penalty":"0"
}
curl example:
curl https://yourserver.com/api/voice/queues/59/users -H 'Content-Type: application/json' -d '{"id":59,"ids":[24,26,31],"penalty":"0"}' -v -u admin:password -X POST
Add one or more agents to List
POST /api/cm/lists/{ListId}/users
BODY:
{
"id":{ListId},
"ids":[
AgentId1,
AgentId2,
AgentId3
...
]
}
curl example:
curl https://yourserver.com/api/cm/lists/32/users -H 'Content-Type: application/json' -d '{"id":32,"ids":[24,26,31]}' -v -u admin:password -X POST
Add one or more contact to a list
POST /api/cm/lists/{ListId}/contacts
BODY:
[
{
"ListId":{ListId},
"firstName":"test1",
"lastName":"asdasd",
"phone":"123456789",
"cf_1":"qwertyuio"
},
{
"ListId":{ListId},
"firstName":"test2",
"lastName":"qweqwe",
"phone":"098765432",
"cf_3":"asdfghjk"
}
]
curl example:
curl https://yourserver.com/api/cm/lists/32/contacts -H 'Content-Type: application/json' -d '[{"ListId":32,"firstName":"test1","lastName":"asdasd","phone":"123456789","cf_1":"qwertyuio"},{"ListId":32,"firstName":"test2","lastName":"asdasd","phone":"098765432","cf_3":"asdfghjk"}]' -v -u admin:password -X POST
Add contacts through csv file
This needs two APIs to be called in sequence
- POST /api/cm/contacts/upload
-H 'content-type: application/x-www-form-urlencoded' \
--data-binary '@/path/to/file.csv'
- POST /api/cm/contacts/upload/file.csv
BODY:
{
"id":"file.csv",
"binding":{ //these are the binding for the contact values with the csv columns, like contactField:csvColumn
"firstName":"Nome",
"phone":" telefono"
},
"ListId":{ListId},
"duplicates":["phone"] //here you can specify if you want to check on duplicated contacts based on one or more specific fields, to avoid adding them again. It's recommended to check on the phone.
}
curl example:
- curl https://yourserver.com/api/cm/contacts/upload -H 'content-type: application/x-www-form-urlencoded'--data-binary '@/usr/tmp/mylist.csv' -v -u admin:password -X POST
2. curl https://yourserver.com/api/cm/contacts/upload/mylist.csv -H 'Content-Type: application/json' -d '{"id":"file.csv","binding":{"firstName":"Nome","phone":" telefono"},"ListId":32,"duplicates":["phone"]}' -v -u admin:password -X POST