cscの作法 その267

# 概要
cscの作法、調べてみた。
「Chaplus API」使って、みた。

# 参考にしたページ

https://qiita.com/maKunugi/items/b1afb6441571119729a7

# サンプルコード

```
using System.Collections;
using System.IO;
using System;
using System.Text;
using LitJson;
using System.Net;

namespace app
{
	class test0 {
		static void Main() {
			ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
			WebClient wc = new WebClient();
			string json = "{\"utterance\": \"おはよう\",\"username\": \"太郎\", \"addition\": {\"utterancePairs\": [{\"utterance\": \"\"}],\"ngWords\": [\"NGワード\"],\"options\": [\"\"]},\"agentState\": {\"agentName\": \"エージェント\",\"age\":\"10歳\",\"tone\": \"normal\"}}";
			Console.WriteLine(json);
			wc.Encoding = System.Text.Encoding.UTF8;
			wc.Headers[HttpRequestHeader.ContentType] = "application/json";
			string response = wc.UploadString("https://www.chaplus.jp/v1/chat?apikey=*****", "POST", json);
			Console.WriteLine(response);
		}
	}
}

```

# 実行結果


```
>chat0
{"utterance": "おはよう","username": "太郎", "addition": {"utterancePairs": [{"utterance": ""}],"ngWords": ["NGワード"],"options": [""]},"agentState": {"agentName": "エージェント","age":"10歳","tone": "normal"}}
{"agentId":"","utterance":"おはよう","username":"太郎","keyword":"","agentState":{"agentName":"エージェント","age":"10歳","tone":"normal"},"addition":{"ngWords":["NGワード"],"utterancePairs":[{"utterance":"","response":"","options":""}],"addSentences":null,"unknownResponses":null,"options":[""],"qaSet":null},"history":null,"useGpt2":false,"gpt2Query":"","gpt2Persona":"","bestResponse":{"utterance":"ございます。 ゆっくりと疲れを癒して良い明日を迎えてください。","score":0.75,"url":"","options":null,"gpt2Response":""},"responses":[{"utterance":"ございます。 ゆっくりと疲れを癒して良い明日を迎えて ください。","score":0.75,"url":"","options":null,"gpt2Response":""},{"utterance":"良い朝を迎えてね\n","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"気持ちいい朝を迎えられた？今日も肩の力抜いていこ\n","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"ぐもに?\n","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"おはよう！今日も1日張り切ってこうね。","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"おはようございます、太郎","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"おはよう、早起きだね。頑張ってる姿はかっこいいです。","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"おっは?\n","score":0.7282,"url":"","options":null,"gpt2Response":""},{"utterance":"いい朝むかえたー？\n","score":0.7282,"url":"","options":null,"gpt2Response":""}],"tokenized":["感動詞,*,*,*,*,*,おはよう,オハヨウ,オハヨー"],"options":["寝坊してしまった・・","朝起きるのが辛い","今日は寒いな","ラジオ体操しませんか？","朝起きるのが辛い","秋は何しよう","早起きだね"," 今日は何する予定？","よく眠れた","おしゃれしたい","喫茶店でお茶してます","寒くて風邪をひきそう","納豆は混ぜすぎない方が おいしいな","寝坊した","今日は何か良い出会いがないものか・・・？","あんまりやる気が出ないな","朝ごはんの皿を洗うのが面倒臭 い","人はみんな平等","朝から怒ってしまった","通勤ラッシュ","夏は何しよう","スタバでMac開いてます","いつ行動するのか","明日が来るのが嫌だ","まだ目が冴えません","朝食にコーンフレークは邪道ですか？","朝からカレーはやりすぎですか？","仕事行こうとしたけどお腹が痛いな","通勤ラッシュが辛いです","どうしたらいい","仕事行きたくない","二日酔いみたいです","犯罪がなくな らないね","仕事行きたくない","布団から出れません","今日は計画的に過ごす","仕事行きたくない","憂鬱な朝","今日の天気は？","雨が降りそう","今、通学中だよ","じゃんけんグー","毎日がエブリデイ","今日の運勢は？","午前中は寝ていたい","サイコロを振 る","満員電車つらい","遅刻しそうだ、どうしよう","今日はなんの日？","まだ朝食食べてない","パンにジャムを塗ります","今、トイレにこもってます","目玉焼きの焼き方を間違えた","健康","朝ごはんを抜く","朝はパン派ですか？ご飯派ですか？","今、通勤中 です","朝が苦手","朝バナナは本当に効果があるんですか？","朝はテレビを見ます","人工知能に朝という概念はあるの？","トイレ にこもってます","花粉が今日は飛んでるかな","ルーレット","仕事に行きたくなくなってしまいました","テレビ","目覚めの良い朝 だね","よく眠れなかった","トイレ行きたい","ウォーキング","冬は何しよう","トイレで新聞読む","朝起きられない","おはよう","引っ越したい","朝つらい","朝だから、散歩でもしようかな","昨日は楽しかった","じゃんけんパー","突然だけど、人生って何だろ う？","通勤ラッシュ","今日も良い1日になるといいな","仕事行きたくない","じゃんけんチョキ","春は何しよう","おみくじ引いて","コーヒーでも飲むか","仕事行きたくない","もうちょっと寝たいが寝坊が怖い","今日は家でゴロゴロ","仕事行きたくない","今日 は暑いな","朝は味噌汁だ","朝ごはん何食べようかな","定時帰宅"]}

```

以上。